<template>
	<view class="container">
		
		
		<u-skeleton
			    rows="20"
			    title
				avatar
				v-bind:loading="loading"
			></u-skeleton>
			
		<template v-if="loading==false">
		<view  class="cell">
			<view class="cell-top">
				<img :src="baseUrl + detail.activityPic" alt="">
			</view>
			<view class="cell-bot">
				<view class="cell-bot0">￥{{detail.activityFee}}</view>
				<view class="cell-bot1">
					<view class="cell-bot1-l">
						{{detail.activityTitle}}
					</view>
				<!-- 	<view class="cell-bot1-r">
						
					</view> -->
				</view>
				<view class="cell-bot2">
					{{detail.activitySubTitle}}
				</view>
				<view class="cell-bot2">
					{{detail.startDate}} ~ {{detail.endDate}}
				</view>
			</view>
		</view>
		<u-divider text="分割线" :dot="true"></u-divider>

		<view class="detail">
			
			<view class="detail-title">
				产品详情
			</view>		
			<view>
				<rich-text :nodes="descs"></rich-text>
			</view>
			 
		</view>
		<view class="kong">
			
		</view>
		
		<view class="btns">
			<view class="btn-l" >
				<button open-type="share" class="sharebtn">		
						
					<uni-icons  type="link" class="link" size="24"></uni-icons>
						<text class="text">分享</text>									 
				</button>
				
			</view>
			<view @click="onSubmit" class="btn-r">
				立即报名
			</view>
		</view>
	</template>
	</view>
</template>

<script>
	import { activityDetail } from './indexServ.js'
	export default {
		name: 'template',
		data() {
			return{
				loading: true,
				baseUrl: getApp().globalData.envParam.baseURL,
				keyword: '',
				show:false,
				activityId:'',
				detail: {
					id:null,
					activityDesc:'',
					activityPic:'',
					startDate:'',
					endDate:'',
					activityFee:'',
					activityTitle:'',
					activitySubTitle:''
				}
			}
		},
		computed:{
			descs(){
				if(this.detail.activityDesc!=''){
					let arr= this.detail.activityDesc.split(',');
					let html= "<div>"
					for(let k in arr){
						arr[k] =`<img src='${this.baseUrl+arr[k]}' style='width:100%!important;height:auto!important;max-height:100%;width:100%;' />`;
						html+=arr[k];
					}
					return html+"</div>";
				}
				return "<div>NOPIC</div>";
			}
		},
		onLoad(op) {
			this.activityId = op.activityId
			uni.showLoading({
				mask:true
			})
			this.GET_activityList()
		},
		methods: {
			onShareAppMessage(res) {
				return {
					title: this.detail.activityTitle,
					path: 'pages/detail/index?activityId='+this.activityId,
					success(res) {
						uni.showToast({
							title: '分享成功'
						})
					},
					fail(res) {
						uni.showToast({
							title: '分享失败',
							icon: 'none'
						})
					}
				}
			},
			onSubmit() {
				uni.navigateTo({
					url: `/pages/commitOrder/index?activityId=` + this.activityId,
					fail: error => {
						console.log('error；', error)
					}
				})
			},

			async GET_activityList() {
				let res = await activityDetail({activityId: this.activityId})
				if(res.code == 200) {
					this.detail = res.data
					//this.detail.activityDesc = this.detail.activityDesc.replace(/<img/gi,
					//		"<img class='richImg'style='width:100%!important;height:auto!important;max-height:100%;width:100%;'"
					//	);
				}
				uni.hideLoading()
				this.loading =false
			},
		}
	}
</script>
<style  lang="scss" scoped>
	.container{
		// padding: 20rpx;
		box-sizing: border-box;
	}
	.search{
		padding: 20rpx;
		box-sizing: border-box;
	}
	.slected{
		width: 100%;
		height: 80rpx;
		background-color: #fff;
		display: flex;
		align-items: center;
		padding: 10rpx 0;
		box-sizing: border-box;
		.item{
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.it2{
			border-left:  2rpx solid #e1e1e1;
			border-right: 2rpx solid #e1e1e1;
		}
	}
	.cell{
		width: 100%;
		background: #fff;
		display: flex;
		flex-direction: column;
		margin-bottom: 40rpx;
		.cell-top{
			width: 100%;
			height: 400rpx;
			// background: pink;
			img{
				width: 100%;
				height: 400rpx;
			}
		}
		.cell-bot{
			width: 100%;
			padding: 20rpx 0rpx;
			box-sizing: border-box;
			.cell-bot0{
				font-size: 34rpx;
				color: #f6511d;
				display: flex;
				align-items: center;
				// justify-content: center;
				padding: 20rpx 10rpx;
			}
			.cell-bot1{
				width: 100%;
				display: flex;
				align-items: center;
				padding: 20rpx 10rpx;
				box-sizing: border-box;
				.cell-bot1-l{
					flex: 1;
					font-size: 34rpx;
					color: #000;
					padding-right: 10rpx;
					box-sizing: border-box;
					word-break: break-all;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2; /* 超出几行省略 */
					overflow: hidden;
					border-right: 2rpx solid #f4f4f4;
				}
				.cell-bot1-r{
					width: 200rpx;
					font-size: 30rpx;
					color: #f6511d;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}
			.cell-bot2{
				width: 100%;
				padding:10rpx 20rpx;
				box-sizing: border-box;
				color: #a9a9a9;
				font-size: 30rpx;
			}
		}
	}
	
	.detail{
		margin-top: 40rpx;
		width: 100%;
		background: #fff;
		.detail-title{
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;
			padding: 0 20rpx;
			box-sizing: border-box;
			border-bottom: 2rpx solid #e1e1e1;
		}
		.detail-img{
			padding: 40rpx 20rpx;
			box-sizing: border-box;
			width: 100%;
			img{
				width: 100%;
			}
		}
	}
	.kong{
		width: 100%;
		height: 120rpx;
	}
	.btns{
		width: 100%;
		height: 100rpx;
		position: fixed;
		left: 0;
		bottom: 0;
		background: #f7f7fa;
		display: flex;
		.btn-l{
			width: 160rpx;
			height: 100rpx;
			border-right: 2rpx solid #e1e1e1;
			border-top: 2rpx solid #e1e1e1;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #888888;			
			font-size: 30rpx;
			
			.sharebtn{
				display: flex;
				justify-content: space-between;
				flex-direction: column;
				width: 100%;
				height: 100rpx;
				.link{
					margin-top: -28rpx;
				}
				.text{
					margin-top: -56rpx;
					font-size: 26rpx;
				}
			}
		}
		.btn-r{
			flex: 1;
			height: 100rpx;
			background: #3c9cff;
			border-top: 2rpx solid #3c9cff;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #fff;
			font-size: 32rpx;
		}
	}
	
	

</style>